#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QPushButton>
#include <QToolButton>
#include <QMenu>
#include <QAction>
#include <QMouseEvent>
#include <QFile>
#include <QFileDialog>
#include <QMessageBox>
#include <QSettings>
#include <QTextCodec>
#include <QPainter>
#include <QPixmap>
#include <QDesktopServices>
#include <QMimeData>
#include <QFileInfo>
#include <QFileIconProvider>

#include "settings.h"
#include "fate.h"
#include "appbutton.h"
#include "stars.h"
#include "mark.h"
#include "suffer.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void init();
    void closeWindow();

//      桌面设置
    void settingWindow();
    void setbackgroundpic(bool, QString);
    void setSize(int, int);
    void setWindowFixed(bool);
    void setWindowOnTop(bool);
    void setWindowBtnAndAppDisplay(bool, bool);
    void setOpacity(int);
    void setDefault();

//      桌面图标
    void btnInit();
    QPoint getBtnXY(int);

//      小工具
//      每日运势
    void showFate();
//      看星星
    void starsWindow();
//      便签
    void markWindow();
//      小游戏
    void sufferWindow();

//      代码编辑器
    void codeWindow();

//      音乐播放器
    void musicWindow();

protected:
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    void enterEvent(QEvent *);
    void leaveEvent(QEvent *);
    void paintEvent(QPaintEvent *event);
    void dragEnterEvent(QDragEnterEvent *event);
    void dropEvent(QDropEvent *event);

private:
    Ui::MainWindow *ui;

    QPushButton *btnClose;
    QPushButton *btnCode;
    QPushButton *btnMusic;
    QPushButton *btnSetting;

    QString fileName;
    QFile *qssFile;

    bool m_move = false;
    QPoint m_startPoint;
    QPoint m_windowPoint;


//      桌面设置
    Settings *settings;  
    int WindowWidth;
    int WindowHeight;
    int windowFixed;
    int windowOnTop;
    int windowBtnDisplay;
    int windowAppDisplay;
    int btnSize;
    int transparentState = 10;
    QString backgroundPic;

//      桌面图标
    int appSize;
    int btnNum;
    AppButton *btn[17];

//      小工具
//      每日运势
    Fate *fate;
//      看星星
    Stars *stars;
//      便签
    Mark *mark;
//      小游戏
    Suffer *suffer;

//      代码编辑器


//      音乐播放器

//      工具栏
    QToolButton *toolBtn;
    QMenu *tool;
    QAction *action_1;
    QAction *action_2;
    QAction *action_3;
    QAction *action_4;
    QAction *action_5;

//    int backgroundNum = 0;
//    const char *gif[4] =
//    {
//        ":/img/test1.png",
//        ":/img/test2.jpg",
//        ":/img/test3.png",
//        ":/img/test4.jpg"
//    };

private slots:
    void openApp();
    void delApp();

};
#endif // MAINWINDOW_H
